package group.igfd.manager.biz.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import group.igfd.manager.biz.entity.GroupInfoEntity;
import group.igfd.manager.biz.service.GroupInfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 在线讨论基本表
 *
 * @author knight
 * @email sunlightcs@gmail.com
 * @date 2018-10-18 10:52:46
 */
@RestController
@RequestMapping("biz/groupInfo")
public class GroupInfoController {
    @Autowired
    private GroupInfoService groupInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("biz:groupInfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = groupInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{groupId}")
    @RequiresPermissions("biz:groupInfo:info")
    public R info(@PathVariable("groupId") String groupId){
			GroupInfoEntity groupInfo = groupInfoService.selectById(groupId);

        return R.ok().put("groupInfo", groupInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("biz:groupInfo:save")
    public R save(@RequestBody GroupInfoEntity groupInfo){
			groupInfoService.insert(groupInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("biz:groupInfo:update")
    public R update(@RequestBody GroupInfoEntity groupInfo){
			groupInfoService.updateById(groupInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("biz:groupInfo:delete")
    public R delete(@RequestBody String[] groupIds){
			groupInfoService.deleteBatchIds(Arrays.asList(groupIds));

        return R.ok();
    }

}
